#include<iostream>
#include "Selection.h"
using namespace std;


void Selection::sort(int* arr, int len) {
	for (int i = 0; i < len-1; i++)
	{
		int minIndex = i;
		for (int j = i+1;  j < len;  j++)
		{
			if (greater(arr[minIndex], arr[j])) {
				minIndex = j;
			}
		}
		exch(arr, i, minIndex);
	}
}


bool Selection::greater(int v, int w) {
	if (v > w) {
		return true;
	}
	return false;
}

void Selection::exch(int* arr, int i, int j) {
	int temp = arr[i];
	arr[i] = arr[j];
	arr[j] = temp;
}


void main04() {
	int arr[] = { 7,6,5,4,3,2,1 };
	int len = sizeof(arr) / sizeof(arr[0]);
	Selection s;
	s.sort(arr, len);
	for (int i = 0; i < len; i++)
	{
		cout << arr[i] << endl;
	}
}